package com.xiaoshuidi.cloud.module.rooms.api.sdiot;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.iot.api.device.vo.AddPassword;
import com.xiaoshuidi.cloud.module.iot.common.ResultModel;
import com.xiaoshuidi.cloud.module.rooms.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.rooms.vo.*;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient(name = ApiConstants.SERVERNAME)
public interface IotRoomDeviceApi {

    String PREFIX = ApiConstants.PREFIX + "/iotRoomDevice";

    @PostMapping(PREFIX + "/getWaringConfig")
    @Operation(summary = "获取预警配置信息")
    CommonResult<List<RoomSdiotWaringVo>> getWaringConfig();

    @PostMapping(PREFIX + "/getDevicePrice")
    @Operation(summary = "获取阶梯水电价格")
    CommonResult<List<PriceInfo>> getDevicePrice(@RequestParam("deviceNo") String deviceNo, @RequestParam("deviceType") String deviceType);

    @PostMapping(PREFIX + "/getDevicePeakValleyPrice")
    @Operation(summary = "获取峰谷水电价格")
    CommonResult<List<RoomDevicePeakValleyPriceVo>> getDevicePeakValleyPrice(@RequestParam("deviceNo") String deviceNo, @RequestParam("deviceType") String deviceType);

    /**
     * 交房自动下发密码（在线）
     *
     * @param addPasswordModel
     * @return
     */
    @PostMapping(PREFIX + "/password/addPassword")
    public ResultModel<AddPassword> addPassword(@RequestBody AddPassword addPasswordModel);

    /**
     * 清除密码操作记录
     *
     * @param roomHouseId
     * @return
     */
    @PostMapping(PREFIX + "/password/clearPassword")
    ResultModel clearPassword(@RequestParam("roomHouseId") Long roomHouseId);

    /**
     * 清除密码操作记录
     *
     * @param roomHouseId
     * @param mobiles     承租人、同住人手机号集合
     * @return
     */
    @PostMapping(PREFIX + "/password/clearPassword1")
    ResultModel clearPassword1(@RequestParam("roomHouseId") Long roomHouseId, @RequestParam("mobiles") List<String> mobiles);

    /**
     * 获取最后一次抄表记录
     *
     * @param roomHouseId
     * @return
     */
    @PostMapping(PREFIX + "/device/getDosage")
    ResultModel<DevicePayTypeVo> getDosage(@RequestParam("roomHouseId") Long roomHouseId);

    /**
     * 根据电话号码清除密码
     *
     * @return
     */
    @GetMapping(PREFIX + "/password/deletePassWordByMobile")
    public ResultModel deletePassWordByMobile(@RequestParam("roomHouseId") Long roomHouseId, @RequestParam("mobile") String mobile);

    /**
     * 新增预警信息
     *
     * @param roomSdiotWaringVo
     * @return
     */
    @PostMapping(PREFIX + "/waring/insertWaring")
    public ResultModel insertWaring(@RequestBody RoomWaringInfoVo roomSdiotWaringVo);

    /**
     * 根据房源id获取已绑定设备信息
     *
     * @param roomHouseId
     * @return
     */
    @PostMapping(PREFIX + "/device/getDeviceInfoByRoomId")
    ResultModel<List<RoomSdiotDeviceMappingVo>> getDeviceInfoByRoomId(@RequestParam("roomHouseId") Long roomHouseId);

    /**
     * 根据deviceNo获取房间信息
     *
     * @param deviceNo
     * @return
     */
    @PostMapping(PREFIX + "/device/getRoomInfoByDeviceNo")
    ResultModel<RoomSdiotDeviceMappingVo> getRoomInfoByDeviceNo(@RequestParam("deviceNo") String deviceNo, @RequestParam("deviceType") String deviceType);

    /**
     * 根据房间id供水供电
     *
     * @param roomHouseId
     * @return
     */
    @PostMapping(PREFIX + "/device/setSwitchOn")
    ResultModel<Boolean> setWaterMeterAndAmmeterSwitchOn(@RequestParam("roomHouseId") Long roomHouseId);

    /**
     * 根据房间id断水断电
     *
     * @param roomHouseId
     * @return
     */
    @PostMapping(PREFIX + "/device/setSwitchOff")
    ResultModel<Boolean> setWaterMeterAndAmmeterSwitchOff(@RequestParam("roomHouseId") Long roomHouseId);

    /**
     * 根据设备编号查询门锁激活码
     *
     * @param deviceNo
     * @return
     */
    @PostMapping(PREFIX + "/query/doorlock/cdkey")
    CommonResult<RoomDoorlockCdkeyVo> queryRoomDoorlockCdkeyByDeviceNo(@RequestParam("deviceNo") String deviceNo);

    /**
     * 根据设备编号查询当前房间入住合同信息
     * @param deviceNo
     * @return
     */
    @PostMapping(PREFIX + "/query/roomContract")
    ResultModel<RoomContractVO> queryRoomContract(@RequestParam("deviceNo") String deviceNo);

}
